package antrace;

public class GroundGameLayer extends AbstractGameLayer {
	
	static int blockWidth = 36;
	
	public GroundGameLayer() {

		super(blockWidth, 14,  AntRace.midlet.loadImage("/images/tiles/groundtiles.png").image, 20, 20);
	
		byte[] cells = {
				0,  0,  0,  4,  0,  0,  0,  0,  0,  0,  4,  0,  0,  0,  0,  4,  0,  0,  0,  0,  0,  0,  4,  0,  0,  0,  0,  4,  0,  0,  0,  0,  0,  0,  4,  0,//	0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
				1,  3,  3,  2,  1,  3,  1,  1,  3,  1,  2,  3,  1,  3,  3,  2,  1,  3,  1,  1,  3,  1,  2,  3,  1,  3,  3,  2,  1,  3,  1,  1,  3,  1,  2,  3,//	1,  3,  1,  3,  1,  3,  3,  3,  1,  3,  1,  1,  3,  1,  3,  3,  1,  3,  1,  2,  1,  1,  1,  1,
				7,	5,	5,	6,	5,	5,	5,	5,	7,	7,	6,	7,  7,	5,	5,	6,	5,	5,	5,	5,	7,	7,	6,	7,  7,	5,	5,	6,	5,	5,	5,	5,	7,	7,	6,	7,//	7,	7,	6,	5,	7,	5,	7,	5,	7,	7,	7,	5,	5,	7,	7,	6,	5,	6,	7,	5,	6,	6,	5,	5,
				6,	5,	6,	7,	7,	7,	6,	5,	6,	7,	7,	6,  6,	5,	6,	7,	7,	7,	6,	5,	6,	7,	7,	6,  6,	5,	6,	7,	7,	7,	6,	5,	6,	7,	7,	6,//	5,	5,	6,	5,	7,	7,	6,	7,	7,	6,	5,	6,	7,	7,	7,	7,	7,	6,	7,	7,	7,	5,	5,	7,
				7,	7,	7,	5,	5,	7,	6,	7,	6,	7,	5,	7,  7,	7,	7,	5,	5,	7,	6,	7,	6,	7,	5,	7,  7,	7,	7,	5,	5,	7,	6,	7,	6,	7,	5,	7,//	5,	6,	5,	5,	5,	5,	5,	5,	6,	6,	6,	7,	6,	6,	6,	5,	7,	7,	6,	5,	7,	5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6,//	6,	5,	5,	6,	7,	6,	7,	6,	5,	7,	6,	5,	6,	7,	5,	6,	6,	7,	7,	7,	7,	5,	5,	5,
				5,	5,	6,	5,	5,	5,	7,	5,	6,	7,	6,	6,  5,	5,	6,	5,	5,	5,	7,	5,	6,	7,	6,	6,  5,	5,	6,	5,	5,	5,	7,	5,	6,	7,	6,	6,//	5,	5,	7,	5,	6,	6,	5,	6,	7,	6,	6,	6,	5,	7,	5,	5,	6,	7,	6,	5,	7,	5,	7,	7,
				7,	7,	5,	7,	5,	7,	7,	6,	7,	6,	7,	6,  7,	7,	5,	7,	5,	7,	7,	6,	7,	6,	7,	6,  7,	7,	5,	7,	5,	7,	7,	6,	7,	6,	7,	6,//	7,	6,	6,	6,	7,	5,	6,	5,	7,	6,	7,	5,	6,	7,	5,	5,	7,	7,	7,	5,	5,	7,	6,	5,
				7,	6,	7,	5,	5,	6,	7,	6,	6,	7,	5,	7,  7,	6,	7,	5,	5,	6,	7,	6,	6,	7,	5,	7,  7,	6,	7,	5,	5,	6,	7,	6,	6,	7,	5,	7,//	5,	7,	5,	5,	7,	5,	5,	7,	5,	7,	5,	6,	6,	7,	5,	6,	5,	5,	6,	5,	5,	7,	7,	7,
		};
		

		this.createTiledLayerFromArray(cells, blockWidth);
		this.setPosition(0, 40);
	}

	public void scroll(int dx) {
		dx *= -1;
		int x = this.getX() + dx;
		
		// När lagret tar slut, börja om från början... (oändligt repterande bakgrund)
		//x = x % (this.getWidth()-240);
		if(this.getX() < -2*12*20)
			x += 2*12*20;
		else if(this.getX() > 0)
			x -= 2*12*20;
		
		
		//System.out.println(this.getWidth());
		this.setPosition(x, this.getY());
	}	
	
	public void reset() {
		this.setPosition(0, 40);
	}
	
	public void collide(AntSprite sprite) {
		// TODO Här görs inget just nu
	}

	public void update() {
		// TODO Här görs inget just nu
	}
}
